{% extends "BackendBundle::backend.html.twig" %}

{% set vars = {'ruta' : app.request.attributes.get('_route')} %}

{% block title %}{{ "Administracion Articulo"|trans }}{% endblock %}

{% if modi == 2 %}

    {% set titulo = "" %}
    {% set contenido = "" %}
    {% set publicado = "" %}

    {% set relacio = "" %}

    {% set titletag = "" %}
    {% set keywordstag = "" %}
    {% set desctag = "" %}
    {% set urlfriendlytag = "" %}

{% elseif modi == 1 %}

    {% set titulo = articletradus.titulo %}
    {% set contenido = articletradus.contenido %}
    {% set publicado = articletradus.published %}

    {% set relacio = articlerelacio.idseccion %}

    {% set titletag = articlemetas.title %}
    {% set keywordstag = articlemetas.keywords %}
    {% set desctag = articlemetas.description %}
    {% set urlfriendlytag = articlemetas.urlfriendly %}

{% else %}
    
    {% set titulo = "" %}
    {% set contenido = "" %}
    {% set publicado = "" %}

    {% set relacio = "" %}

    {% set titletag = "" %}
    {% set keywordstag = "" %}
    {% set desctag = "" %}
    {% set urlfriendlytag = "" %}
    
{% endif %}

{% block css %}
             
{% endblock %}

{% block js %}

    <script src="{{ asset('bundles/content/js/jscripts/tiny_mce/jquery.tinymce.js') }}"></script>
   
    <script type="text/javascript">
        
	$().ready(function() {
            
            $('textarea.tinymce').tinymce({

                // Location of TinyMCE script
                script_url : '{{ asset('bundles/content/js/jscripts/tiny_mce/tiny_mce.js') }}',

                // General options
                theme : "advanced",
                plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

                // Theme options
                theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
                theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,code",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_resizing : false,

                // Example content CSS (should be your site CSS)
                content_css : "{{ asset('bundles/content/css/content.css') }}"

            });
            
	});
        
    </script>

{% endblock %}

{% block header %}

    {% include "BackendBundle::topmenu.html.twig" with vars %}

{% endblock %}

{% block left %}

    {% include "ContentBundle:Hotel:menuleft.html.twig" with vars %}

{% endblock %}

{% block content %}

    <div class="span9">
    
        <h2>{{ "Contenido"|trans }}</h2>

        <fieldset>
            
            {% if modi == 2 %}
                <legend>{{ "Traduccion Articulo"|trans }}</legend>
            {% elseif modi == 1 %}
                <legend>{{ "Modificando Articulo"|trans }}</legend>
            {% else %}
                <legend>{{ "Añadir articulo para"|trans }} "{{hotel.hotelname}}"</legend>
            {% endif %}            
            
            {% if app.session.hasFlash('success') %}
                <div class="flash-notice alert alert-success">
                    <h4 class="alert-heading">{{ "Ok"|trans }}!</h4>                     
                    {{ app.session.flash('success') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('error') %}
                <div class="flash-notice alert alert-error">
                    <h4 class="alert-heading">{{ "Error"|trans }}!</h4>                        
                    {{ app.session.flash('error') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('info') %}
                <div class="flash-notice alert alert-info">
                    <h4 class="alert-heading">{{ "Info"|trans }}!</h4>
                    <p>{{ app.session.flash('info') }}</p>
                </div>
            {% endif %} 

            {% if modi == 2 %}
            <form action="{{ path('ContentBundle_article_tradu_save') }}" class="form-horizontal" method="post">
            {% elseif modi == 1 %}
            <form action="{{ path('ContentBundle_article_edita_save') }}" class="form-horizontal" method="post">
            {% else %}
            <form action="{{ path('ContentBundle_articles_save') }}" class="form-horizontal" method="post">
            {% endif %} 
                
                <fieldset>
                    
                    <div class="control-group">
                        <label class="control-label" for="titulo">{{ "Titulo"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="titulo" name="titulo" type="text" value="{{ titulo }}" />
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label" for="contenido">Contenido *</label>
                        <div class="controls">
                            <textarea style="width: 500px; height: 400px;" class="input-xlarge tinymce" name="contenido" id="contenido" rows="3">{{ contenido }}</textarea>
                        </div>
                    </div>

                    {% if modi != 2 %}
                    
                    <div class="control-group">
                        <label class="control-label" for="seccion">{{ "Contenido de"|trans }} *</label>
                        <div class="controls">
                            
                            <select id="seccion" name="seccion">
                                
                                {% for ar in arbre %}            
                                    {% if ar.actiu == 1 %}
                                        <option value="{{ ar.id }}"{% if relacio == ar.id %} selected="selected"{% endif %}>{{ ar.text }}</option>
                                    {% else %}
                                        <option disabled="disabled">{{ ar.text }}</option>
                                    {% endif %}
                                {% endfor %}
                                                
                            </select>

                        </div>
                    </div>
                    
                    {% endif %}
                    
                    <div class="control-group">
                        <label class="control-label">{{ "Publicado"|trans }}</label>
                        <div class="controls">
                            <div class="span1">
                                <label class="radio">
                                    <input name="publicado" id="optionsRadios1" value="1" type="radio"{% if publicado == 1 %} checked="checked"{% endif %} />
                                    {{ "Si"|trans }}
                                </label>
                            </div>
                            <div class="span1">   
                                <label class="radio">
                                    <input name="publicado" id="optionsRadios2" value="0" type="radio"{% if publicado == 0 %} checked="checked"{% endif %} />
                                    {{ "No"|trans }}
                                </label>
                            </div>
                        </div>
                    </div>                    
                        
                </fieldset> 
                
                {% if modi != 2 %}
                    
                <fieldset>
                    
                    <legend><small>{{ "Servicios"|trans }}</small></legend>
                    
                    <div class="control-group">
                        
                        {% if servicios|length != 0 %}
                        
                        <label class="control-label" for="optionsCheckboxList">{{ "Servicios disponibles"|trans }}</label>
                        
                        <div class="controls">
                            
                            {% for servicio in servicios %}
                               
                                <label class="checkbox inline span4" style="margin-left: 0px;">
                                    <input name="servicio-{{ servicio.idservicio }}" value="{{ servicio.idservicio }}" type="checkbox"{% if servicio.activo == 1 %} checked="checked"{% endif %} />
                                    {{ servicio.nombreservicio }}
                                </label>
                            
                            {% endfor %}

                        </div>
                        
                        {% else %}
                        
                        <span class="span9">
                            No hay servicios disponibles
                        </span>
                        
                        {% endif %}
                        
                    </div>

                </fieldset>
                    
                {% endif %}
                    
                <fieldset>
                    
                    <legend><small>{{ "Metatags"|trans }}</small></legend>

                    <div class="control-group">
                        <label class="control-label" for="titletag">{{ "Title"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="titletag" name="titletag" type="text" value="{{ titletag }}" />
                        </div>
                    </div>                  
                    <div class="control-group">
                        <label class="control-label" for="Keywordstag">{{ "Keywords"|trans }}</label>
                        <div class="controls">
                            <input class="input-xlarge" id="Keywordstag" name="Keywordstag" type="text" value="{{ keywordstag }}" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="desctag">{{ "Description"|trans }}</label>
                        <div class="controls">
                            <textarea class="input-xlarge" name="desctag" id="desctag" rows="3">{{ desctag }}</textarea>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label" for="urlfriendlytag">{{ "Url Friendly"|trans }} *</label>
                        <div class="controls">
                            <input class="input-xlarge" id="urlfriendlytag" name="urlfriendlytag" type="text" value="{{ urlfriendlytag }}" />
                        </div>
                    </div>                      
                        
                    <div class="form-actions">
                        
                        {% if modi == 2 %}
                            <button type="submit" name="DadesGuardaCrea" class="btn btn-primary">{{ "Guardar traduccion"|trans }}</button>
                            <a href="{{ path("ContentBundle_articles_list_idioma", {'ididioma': ididioma}) }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% elseif modi == 1 %}
                            <button type="submit" name="DadesGuardaModi" class="btn btn-primary">{{ "Guardar"|trans }}</button>
                            <a href="{{ path("ContentBundle_articles_list_idioma", {'ididioma': ididioma}) }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% else %}
                            <button type="submit" name="DadesGuarda" class="btn btn-primary">{{ "Añadir Articulo"|trans }}</button>
                            <a href="{{ path('ContentBundle_articles_list') }}" class="btn">{{ "Cancelar"|trans }}</a>
                        {% endif %}

                    </div>
                </fieldset>
                    
            </form>

        </fieldset>
        
    </div>

{% endblock %}
